home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / swtools / malloc_db / README < prev    next >
Encoding:
Text File  |  1994-08-02  |  2.9 KB  |  76 lines

  1.   
  2.   
  3.                         malloc_db.c by Gianni Mariani 
  4.                                 18-Feb-1992 
  5.   
  6.   
  7.       A heap trasher finder.
  8.   
  9.       Finding bugs trashing the heap can be a REAL PAIN since all the
  10.       debugger tells you is :-
  11.   
  12.       +---------------------------------------------------+
  13.       | Core from signal SIGBUS: Bus error                |
  14.       | free(<stripped>) ["malloc.c":791, 0x401004]       |
  15.       +---------------------------------------------------+
  16.   
  17.       Not very usefull, probably not even if you had malloc.c !
  18.   
  19.       However if you had this :-
  20.   
  21.       +-----------------------------------------------------------+
  22.       | malloc_db.c:290 found heap trashing                       |
  23.       |         diagnotic : (unsure - back/forward link wrong 5)  |
  24.       | db_bugptr1 = 0x10020cf0                                   |
  25.       | db_bugptr2 = 0x100200b0                                   |
  26.       | db_bugptr3 = 0x10020cf8                                   |
  27.       | db_bugptr4 = 0x100200b4                                   |
  28.       | ->>>dumping core                                          |
  29.       | Segmentation fault (core dumped)                          |
  30.       +-----------------------------------------------------------+
  31.   
  32.       Given that db_bugptr3 and db_bugptr4 usually contain pointers
  33.       to actual corrupted locations you can proceed to set watch 
  34.       points on them and find the actual code that writes on them.
  35.   
  36.       In this directory you will find :
  37.           malloc_db.c  - the star of this show
  38.           test.c       - a test program for malloc heap trashing
  39.           Makefile     - a makefile to generate test test_clib and 
  40.                          test_mdb
  41.           README       - me
  42.   
  43.           Makefile output :
  44.           test         - executable with no heap trash checking.
  45.           test_clib    - provides the checking that libmalloc.a
  46.                          provides through mallopt()
  47.           test_mdb     - is the test execuatble using malloc_db.c.
  48.   
  49.       The heading comment in malloc_db.c provides most of the 
  50.       information that you need to use malloc_db.c.
  51.   
  52.       As an example you may wish to set "watch/trace points" using cvd 
  53.       or dbx on the values of db_bugptr3 and db_bugptr4 of the output 
  54.       of test_mdb to see how it works on test_mdb.  again see the top
  55.       of malloc_db.c for all the details.
  56.   
  57.       Happy malloc_db-ing.
  58.   
  59.       Bonza
  60.       Gianni
  61.       
  62.  
  63.  
  64.       p.s.  due to the nature of technologic, there is now way to 
  65.             get rid of warning messages such as
  66.             
  67. Warning: malloc: multiply defined
  68.         previous (used) definition from 'malloc_db.o';
  69.         new (ignored) definition from '/usr/lib/libmpc.a'
  70.  
  71.             that start barking at you when compiling test_mdb, 
  72.             since the malloc module itself contains the definitions 
  73.             to malloc, free, realloc etc.  we are all just going 
  74.             to have to live with it!
  75.  
  76.